package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallCollect;
import org.apache.ibatis.jdbc.SQL;

public class HaogoumallCollectSqlProvider {

    public String insertSelective(HaogoumallCollect record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("haogoumall_collect");
        
        if (record.getCollectId() != null) {
            sql.VALUES("collect_id", "#{collectId,jdbcType=INTEGER}");
        }
        
        if (record.getUserId() != null) {
            sql.VALUES("user_id", "#{userId,jdbcType=INTEGER}");
        }
        
        if (record.getCollectValueId() != null) {
            sql.VALUES("collect_value_id", "#{collectValueId,jdbcType=INTEGER}");
        }
        
        if (record.getCollectType() != null) {
            sql.VALUES("collect_type", "#{collectType,jdbcType=TINYINT}");
        }
        
        if (record.getCollectAddTime() != null) {
            sql.VALUES("collect_add_time", "#{collectAddTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCollectUpdateTime() != null) {
            sql.VALUES("collect_update_time", "#{collectUpdateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCollectDeleted() != null) {
            sql.VALUES("collect_deleted", "#{collectDeleted,jdbcType=BIT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(HaogoumallCollect record) {
        SQL sql = new SQL();
        sql.UPDATE("haogoumall_collect");
        
        if (record.getUserId() != null) {
            sql.SET("user_id = #{userId,jdbcType=INTEGER}");
        }
        
        if (record.getCollectValueId() != null) {
            sql.SET("collect_value_id = #{collectValueId,jdbcType=INTEGER}");
        }
        
        if (record.getCollectType() != null) {
            sql.SET("collect_type = #{collectType,jdbcType=TINYINT}");
        }
        
        if (record.getCollectAddTime() != null) {
            sql.SET("collect_add_time = #{collectAddTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCollectUpdateTime() != null) {
            sql.SET("collect_update_time = #{collectUpdateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCollectDeleted() != null) {
            sql.SET("collect_deleted = #{collectDeleted,jdbcType=BIT}");
        }
        
        sql.WHERE("collect_id = #{collectId,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}